class Admin::BaseMaterialsController < ApplicationController
  # GET /admin/base_materials
  # GET /admin/base_materials.xml
  def index
    @base_materials = BaseMaterial.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @base_materials }
    end
  end

  # GET /admin/base_materials/1
  # GET /admin/base_materials/1.xml
  def show
    @base_material = BaseMaterial.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @base_material }
    end
  end

  # GET /admin/base_materials/new
  # GET /admin/base_materials/new.xml
  def new
    @base_material = BaseMaterial.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @base_material }
    end
  end

  # GET /admin/base_materials/1/edit
  def edit
    @base_material = BaseMaterial.find(params[:id])
  end

  # POST /admin/base_materials
  # POST /admin/base_materials.xml
  def create
    @base_material = BaseMaterial.new(params[:base_material])

    respond_to do |format|
      if @base_material.save
        flash[:notice] = 'BaseMaterial was successfully created.'
        format.html { redirect_to([:admin, @base_material]) }
        format.xml  { render :xml => @base_material, :status => :created, :location => @base_material }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @base_material.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /admin/base_materials/1
  # PUT /admin/base_materials/1.xml
  def update
    @base_material = BaseMaterial.find(params[:id])

    respond_to do |format|
      if @base_material.update_attributes(params[:base_material])
        flash[:notice] = 'BaseMaterial was successfully updated.'
        format.html { redirect_to([:admin, @base_material]) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @base_material.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /admin/base_materials/1
  # DELETE /admin/base_materials/1.xml
  def destroy
    @base_material = BaseMaterial.find(params[:id])
    @base_material.destroy

    respond_to do |format|
      format.html { redirect_to(admin_base_materials_url) }
      format.xml  { head :ok }
    end
  end
end
